package com.zhongxi.guoyuan.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.zhongxi.guoyuan.R;
import com.zhongxi.guoyuan.entity.projectItem.ProjectItemData;
import com.zhongxi.guoyuan.utils.CommonTool;

import java.util.List;

import static com.zhongxi.guoyuan.R.id.tv;

/**
 * Created by Administrator on 2017/10/10.
 */

public class TitleCateAdapter extends BaseAdapter {
    private List<ProjectItemData> titleList;
    private Context context;

    public TitleCateAdapter(Context context, List<ProjectItemData> titleList) {
        this.context = context;
        this.titleList = titleList;
    }

    @Override
    public int getCount() {
        if (titleList != null && titleList.size() > 0) {
            return titleList.size();
        }
        return 0;
    }

    @Override
    public Object getItem(int i) {
        return titleList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        if (view == null) {
            view = View.inflate(context, R.layout.item_title, null);
        }
        TextView tv = (TextView) view.findViewById(R.id.tv_item_title);
        ProjectItemData projectItemData = titleList.get(i);
        tv.setText(projectItemData.getName());
        tv.setSelected(projectItemData.isSelect());
        if (projectItemData.isSelect()) {
            tv.setTextColor(context.getResources().getColor(R.color.white));
        }
        return view;
    }
}
